package MenuPrincipal;

import DAO.ClienteDAO;
import DAO.FornecedorDAO;
import DAO.ItemDAO;
import DAO.NotaFiscalDAO;
import DAO.PedidoDAO;
import Pojo.Pedido;
import TelaCliente.TelaBuscarCliente;
import TelaCliente.TelaCadastroCliente;
import TelaCliente.TelaExcluirCliente;
import TelaCliente.TelaListarClientes;
import TelaComprarItens.TelaComprarItem;
import TelaItens.TelaCadastroDeItem;
import TelaItens.TelaListarExcluir;
import TelasFornecedor.CadastroFornecedor1;
import TelasFornecedor.TelaBuscarFornecedor;
import TelasFornecedor.TelaExcluirFornecedor1;
import TelasFornecedor.TelaListarFornecedores;
import TelasPedido.TelaListarExcluirPedido;
import TelasPedido.TelaNovoPedido;
import TelasPedido.TelaPedidosEmAberto;
import TelasPedido.TelaPedidosFechados;
import View.MenuFornecedor;
import View.MenuPedido;
import View.MenuPrincipal;
import java.awt.CardLayout;


public class MenuOpcoes extends javax.swing.JFrame {
    MenuPrincipal menup = new MenuPrincipal();
    MenuFornecedor menuf = new MenuFornecedor();
    MenuPedido menuPedido = new MenuPedido();
    FornecedorDAO fornecedorDao;
    ClienteDAO clienteDao;
    PedidoDAO pedidoDao;
    NotaFiscalDAO notaFiscalDao;
    Pedido pedido;
    ItemDAO itemDao;
    public MenuOpcoes() {
        initComponents();
    }
    public MenuOpcoes(FornecedorDAO fornecedorDao,ClienteDAO clienteDao,ItemDAO itemDao, PedidoDAO pedidoDao, NotaFiscalDAO notaFiscalDao) {
        this();
        this.fornecedorDao = fornecedorDao;
        this.clienteDao = clienteDao;
        this.pedidoDao = pedidoDao;
        this.itemDao = itemDao;
        this.notaFiscalDao = notaFiscalDao;
        this.setLocationRelativeTo(null); 
    }
    
    
                
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton6 = new javax.swing.JButton();
        Root = new javax.swing.JPanel();
        Inicio = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem10 = new javax.swing.JMenuItem();
        jMenuItem11 = new javax.swing.JMenuItem();
        jMenuItem12 = new javax.swing.JMenuItem();
        jMenuItem13 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem6 = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenuItem8 = new javax.swing.JMenuItem();
        jMenuItem9 = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();
        jMenuItem7 = new javax.swing.JMenuItem();
        jMenuItem14 = new javax.swing.JMenuItem();
        jMenu5 = new javax.swing.JMenu();
        jMenuItem15 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Menu de Opcões");
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setResizable(false);

        jButton6.setText("Sair");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        Root.setLayout(new java.awt.CardLayout());

        jLabel1.setIcon(new javax.swing.ImageIcon("C:\\Users\\DanielPC\\Pictures\\prog3 DHV.jpg")); // NOI18N

        javax.swing.GroupLayout InicioLayout = new javax.swing.GroupLayout(Inicio);
        Inicio.setLayout(InicioLayout);
        InicioLayout.setHorizontalGroup(
            InicioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(InicioLayout.createSequentialGroup()
                .addGap(108, 108, 108)
                .addComponent(jLabel1)
                .addContainerGap(118, Short.MAX_VALUE))
        );
        InicioLayout.setVerticalGroup(
            InicioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, InicioLayout.createSequentialGroup()
                .addContainerGap(80, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addGap(73, 73, 73))
        );

        Root.add(Inicio, "Inicio");

        jMenu1.setText("Fornecedor");

        jMenuItem1.setText("Cadastrar");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuItem2.setText("Excluir");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);

        jMenuItem3.setText("Listar");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem3);

        jMenuItem4.setText("Buscar");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem4);

        jMenuBar1.add(jMenu1);

        jMenu3.setText("Cliente");

        jMenuItem10.setText("Cadastrar Cliente");
        jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem10ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem10);

        jMenuItem11.setText("Buscar Cliente");
        jMenuItem11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem11ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem11);

        jMenuItem12.setText("Listar Cliente");
        jMenuItem12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem12ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem12);

        jMenuItem13.setText("Excluir Cliente");
        jMenuItem13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem13ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem13);

        jMenuBar1.add(jMenu3);

        jMenu2.setText("Pedido");

        jMenuItem6.setText("Novo Pedido");
        jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem6ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem6);

        jMenuItem5.setText("Fechar Pedido");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem5);

        jMenuItem8.setText("Pedidos Fechados");
        jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem8ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem8);

        jMenuItem9.setText("Listar/Alterar/Excluir");
        jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem9ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem9);

        jMenuBar1.add(jMenu2);

        jMenu4.setText("Itens");

        jMenuItem7.setText("Cadastrar Item Novo");
        jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem7ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem7);

        jMenuItem14.setText("Listar/Excluir Itens");
        jMenuItem14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem14ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem14);

        jMenuBar1.add(jMenu4);

        jMenu5.setText("Compra");

        jMenuItem15.setText("Comprar Itens");
        jMenuItem15.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem15ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem15);

        jMenuBar1.add(jMenu5);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(Root, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(35, 35, 35))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(Root, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton6)
                .addGap(6, 6, 6))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
            System.exit(0);
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        //Opcao 2 do menu fornecedor: Excluir
        CardLayout card = (CardLayout) Root.getLayout();
        TelaExcluirFornecedor1 telaExcluirFornecedor = new TelaExcluirFornecedor1(fornecedorDao);
        Root.add(telaExcluirFornecedor, "Fornecedor");
        ((CardLayout) Root.getLayout()).show(Root, "Fornecedor");
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        CardLayout card = (CardLayout) Root.getLayout();
        TelaListarFornecedores telaListarFornecedores = new TelaListarFornecedores(fornecedorDao);
        Root.add(telaListarFornecedores, "Fornecedor");
        ((CardLayout) Root.getLayout()).show(Root, "Fornecedor");
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        //Opcao 1 do Menu Fornecedor:
        CardLayout card = (CardLayout) Root.getLayout();
        CadastroFornecedor1 cadastroFornecedor1 = new CadastroFornecedor1(fornecedorDao);
        Root.add(cadastroFornecedor1, "Fornecedor");
        ((CardLayout) Root.getLayout()).show(Root, "Fornecedor");
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
        CardLayout card = (CardLayout) Root.getLayout();
        TelaBuscarFornecedor telaBuscarFornecedor = new TelaBuscarFornecedor(fornecedorDao);
        Root.add(telaBuscarFornecedor, "Fornecedor");
        ((CardLayout) Root.getLayout()).show(Root, "Fornecedor");
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
        // TODO add your handling code here:
        
        CardLayout card = (CardLayout) Root.getLayout();
        TelaNovoPedido telaNovoPedido = new TelaNovoPedido(itemDao, clienteDao, pedidoDao,notaFiscalDao);
        Root.add(telaNovoPedido, "Fornecedor");
        ((CardLayout) Root.getLayout()).show(Root, "Fornecedor");
    }//GEN-LAST:event_jMenuItem6ActionPerformed

    private void jMenuItem11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem11ActionPerformed
        // TODO add your handling code here:
        CardLayout card = (CardLayout) Root.getLayout();
        TelaBuscarCliente telaBuscarClinete = new TelaBuscarCliente(clienteDao);
        Root.add(telaBuscarClinete, "Fornecedor");
        ((CardLayout) Root.getLayout()).show(Root, "Fornecedor");
    }//GEN-LAST:event_jMenuItem11ActionPerformed

    private void jMenuItem10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem10ActionPerformed
        // TODO add your handling code here:
        CardLayout card = (CardLayout) Root.getLayout();
        TelaCadastroCliente telaCadastroCliente = new TelaCadastroCliente(clienteDao);
        Root.add(telaCadastroCliente, "Fornecedor");
        ((CardLayout) Root.getLayout()).show(Root, "Fornecedor");

    }//GEN-LAST:event_jMenuItem10ActionPerformed

    private void jMenuItem12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem12ActionPerformed
        // TODO add your handling code here:
        CardLayout card = (CardLayout) Root.getLayout();
        TelaListarClientes telaListarClientes = new TelaListarClientes(clienteDao);
        Root.add(telaListarClientes, "Fornecedor");
        ((CardLayout) Root.getLayout()).show(Root, "Fornecedor");
    }//GEN-LAST:event_jMenuItem12ActionPerformed

    private void jMenuItem13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem13ActionPerformed
        // TODO add your handling code here:
        
        CardLayout card = (CardLayout) Root.getLayout();
        TelaExcluirCliente telaExcluirCliente = new TelaExcluirCliente(clienteDao);
        Root.add(telaExcluirCliente, "Fornecedor");
        ((CardLayout) Root.getLayout()).show(Root, "Fornecedor");
    }//GEN-LAST:event_jMenuItem13ActionPerformed

    private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed
        // TODO add your handling code here:
        CardLayout card = (CardLayout) Root.getLayout();
        TelaListarExcluirPedido telaListarExcluirPedido = new TelaListarExcluirPedido(pedidoDao,itemDao);
        Root.add(telaListarExcluirPedido, "Fornecedor");
        ((CardLayout) Root.getLayout()).show(Root, "Fornecedor");
    }//GEN-LAST:event_jMenuItem9ActionPerformed

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
        // TODO add your handling code here:
        CardLayout card = (CardLayout) Root.getLayout();
        TelaPedidosEmAberto telaPedidosEmAberto = new TelaPedidosEmAberto(pedidoDao,notaFiscalDao,itemDao);
        Root.add(telaPedidosEmAberto, "Fornecedor");
        ((CardLayout) Root.getLayout()).show(Root, "Fornecedor");
    }//GEN-LAST:event_jMenuItem5ActionPerformed

    private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed
        // TODO add your handling code here:
        
        CardLayout card = (CardLayout) Root.getLayout();
        TelaPedidosFechados telaPedidosFechados = new TelaPedidosFechados(notaFiscalDao,pedidoDao,itemDao);
        Root.add(telaPedidosFechados, "Fornecedor");
        ((CardLayout) Root.getLayout()).show(Root, "Fornecedor");
    }//GEN-LAST:event_jMenuItem8ActionPerformed

    private void jMenuItem14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem14ActionPerformed
        // TODO add your handling code here:
        CardLayout card = (CardLayout) Root.getLayout();
        TelaListarExcluir telaListarExcluirItem = new TelaListarExcluir(itemDao);
        Root.add(telaListarExcluirItem, "Fornecedor");
        ((CardLayout) Root.getLayout()).show(Root, "Fornecedor");
    }//GEN-LAST:event_jMenuItem14ActionPerformed

    private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed
        // TODO add your handling code here:
        CardLayout card = (CardLayout) Root.getLayout();
        TelaCadastroDeItem telaCadastroDeItem = new TelaCadastroDeItem(itemDao);
        Root.add(telaCadastroDeItem, "Fornecedor");
        ((CardLayout) Root.getLayout()).show(Root, "Fornecedor");
        
        
    }//GEN-LAST:event_jMenuItem7ActionPerformed

    private void jMenuItem15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem15ActionPerformed
        // TODO add your handling code here:
        CardLayout card = (CardLayout) Root.getLayout();
        TelaComprarItem telaComprarItem = new TelaComprarItem(fornecedorDao,itemDao);
        Root.add(telaComprarItem, "Fornecedor");
        ((CardLayout) Root.getLayout()).show(Root, "Fornecedor");
    }//GEN-LAST:event_jMenuItem15ActionPerformed

    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel Inicio;
    private javax.swing.JPanel Root;
    private javax.swing.JButton jButton6;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenu jMenu5;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem10;
    private javax.swing.JMenuItem jMenuItem11;
    private javax.swing.JMenuItem jMenuItem12;
    private javax.swing.JMenuItem jMenuItem13;
    private javax.swing.JMenuItem jMenuItem14;
    private javax.swing.JMenuItem jMenuItem15;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem8;
    private javax.swing.JMenuItem jMenuItem9;
    // End of variables declaration//GEN-END:variables
}
